home *** CD-ROM | disk | FTP | other *** search
/ Ham Radio 2000 / Ham Radio 2000.iso / ham2000 / qex / dishfd1 / dishfeed.bas < prev    next >
BASIC Source File  |  1996-02-05  |  7KB  |  188 lines

  1. REM  DISHFEED.BAS  ver 1.0                      28 Dec 95    RSL
  2. REM
  3. REM  QBasic program to calculate the efficiency of a parabola as a
  4. REM  function of the feed amplitude characteristics and the f/d of
  5. REM  the dish. Reads the feed amplitude function from a file that has
  6. REM  19 lines corresponding to the dB gain from 0 deg (1st line) to
  7. REM  180 deg (19th line.)  This feed characteristic is assumed to be
  8. REM  axially symmetric so it can be described by a table of numbers from
  9. REM  0 to 180 degrees.  Entries are every 10 degrees and are interpolated
  10. REM  cubicly for integration.
  11. REM
  12. REM  Reference: C. C. Cutler, Parabolic-Antenna Design for Microwaves,
  13. REM             Proceedings of IRE, vol 35, pp1284-1294, Nov 1947
  14. REM  Assumptions:
  15. REM      1 - Amplitude response of feed is axially symmetric for 1 input file
  16. REM          or can be approximated by power average of two patterns for the
  17. REM          two file case.
  18. REM      2 - There are no phase errors from feed.
  19. REM      3 - Diffraction at the dish edge can be ignored (very questionable).
  20. REM      4 - The feed pattern can be described by 10 deg samples.
  21. REM
  22. REM  Also included is a calculation for the (cos x)^n pattern that is often
  23. REM  used as model for dish feeds.
  24. REM
  25. REM  Copyright (C) 1995  Bob Larkin, W7PUA,  boblark@delphi.com
  26. REM  For free use by amateur radio operators for amateur purposes.
  27. REM
  28. REM  Note: this program is not user friendly.  Input errors are not checked.
  29. REM  Also some of the instructions may be in the program as REM's.
  30.  
  31. DIM FEED#(20), IFEED#(180), ETA#(17), ETAS#(17), ETAI#(17), C#(4, 5)
  32. DIM IN1#(180), IN2#(180)
  33. PI# = 3.14159265359#
  34.  
  35. REM Either 1 or 2 files can be used to supply data.  The 2 file case
  36. REM is for E-plane & H-plane patterns and these are then averaged in power.
  37. REM This is a good approximation to a full 2 dim integration for
  38. REM dish feed antennas.
  39. REM The 1 file case should be used if only an E-plane or an
  40. REM H-plane cut is available.
  41. REM Files should have 19 entries on separate lines.  The values should be
  42. REM in dB attenuation relative to the peak gain of the feed.  Thus, there
  43. REM should be a 0.0 entry somewhere and no entries should be negative.
  44.  
  45. INPUT "Enter the number of files for data, 1 or 2, or 3 for cos feeds"; NF%
  46. IF NF% = 1 THEN GOTO GET1
  47. IF NF% = 3 THEN GOTO COSFEEDS
  48. INPUT "Input file name 1, with path and extension, for feed data"; NAMEF1$
  49. OPEN NAMEF1$ FOR INPUT AS #1
  50. INPUT "Input file name 2, with path and extension, for feed data"; NAMEF2$
  51. OPEN NAMEF2$ FOR INPUT AS #2
  52.  
  53. FOR I% = 1 TO 19
  54.    INPUT #1, FEED1#
  55.    PF1# = 10# ^ (-FEED1# / 10#)
  56.    INPUT #2, FEED2#
  57.    PF2# = 10# ^ (-FEED2# / 10#)
  58.    FEED#(I%) = -4.3429448# * LOG(PF1# + PF2#) + 3.01029996#
  59. NEXT I%
  60. GOTO GOTEM
  61.  
  62. GET1:
  63. INPUT "Input file name, including path and extension, for feed data"; NAMEF$
  64. OPEN NAMEF$ FOR INPUT AS #1
  65. FOR I% = 1 TO 19
  66.    INPUT #1, FEED#(I%)
  67. NEXT I%
  68.  
  69. GOTEM:
  70. FOR I% = 1 TO 19
  71.     FEED#(I%) = 10# ^ (-FEED#(I%) / 20#)'Convert to Voltage magnitude
  72. NEXT I%
  73.  
  74. FEED#(0) = FEED#(2)    'Provides symmetry at the axis for interpolation
  75. FEED#(20) = FEED#(18)  'This does it at 180 degrees as well
  76.  
  77. REM Next interpolate 18 times by fitting a cubic through adjacent 4 points
  78. REM and interpolating the polynomial at each degree.
  79. FOR I% = 1 TO 18   'Over all 10 degree sectors
  80.     REM For numerical accuracy, we will always consider angle as (-10, 20)
  81.     FOR J% = 1 TO 4   'Over 4 data points
  82.     C#(J%, 1) = 1
  83.     FOR K% = 2 TO 4  '3 coefficients per equation
  84.         C#(J%, K%) = (10# * (J% - 2)) ^ (K% - 1)
  85.     NEXT K%
  86.     C#(J%, 5) = FEED#(I% + J% - 2)
  87.     NEXT J%
  88.  
  89.     REM Now solve simultaneous equations
  90.     FOR J% = 1 TO 4
  91.     FOR L% = J% TO 4
  92.         IF ABS(C#(L%, J%)) > 1E-10 THEN GOTO NONZ
  93.     NEXT L%
  94. NONZ:        FOR K% = 1 TO 5
  95.         X# = C#(J%, K%)
  96.         C#(J%, K%) = C#(L%, K%)
  97.         C#(L%, K%) = X#
  98.     NEXT K%
  99.     Y# = 1# / C#(J%, J%)
  100.     FOR K% = 1 TO 5
  101.         C#(J%, K%) = Y# * C#(J%, K%)
  102.     NEXT K%
  103.     FOR L% = 1 TO 4
  104.         IF L% = J% THEN GOTO LUP
  105.         Y# = -C#(L%, J%)
  106.         FOR K% = 1 TO 5
  107.         C#(L%, K%) = C#(L%, K%) + Y# * C#(J%, K%)
  108.         NEXT K%
  109. LUP:     NEXT L%
  110.     NEXT J%
  111.     REM  Now interpolate to each degree point
  112.     FOR J% = 0 TO 10
  113.     AJ# = J%
  114.     V# = C#(1, 5) + C#(2, 5) * AJ# + C#(3, 5) * AJ# ^ 2
  115.     V# = V# + C#(4, 5) * AJ# ^ 3
  116.     REM Take care of polynomial approximation near zero:
  117.     IF V# < 0# THEN V# = -V#
  118.     IFEED#(10 * (I% - 1) + J%) = V#
  119.     NEXT J%
  120. NEXT I%
  121.  
  122. DOINT:
  123. REM  Now integrate the interpolated curves to find the antenna efficiencies
  124. REM  Collect integrands, U*tan(theta/2) and U^2 * sin(theta) in IN1(), IN2().
  125. REM  Note that integration period 1 is 0 to 1 degrees and is centered on 0.5
  126. REM  degrees.
  127. DENOM# = 0#
  128. FOR I% = 1 TO 180
  129.     U# = .5# * (IFEED#(I% - 1) + IFEED#(I%))
  130.     THETA# = PI# * (I% - .5) / 180#
  131.     HTHETA# = .5# * THETA#
  132.     IN1#(I%) = U# * TAN(HTHETA#)
  133.     IN2#(I%) = U# * U# * SIN(THETA#)
  134.     DENOM# = DENOM# + IN2#(I%)
  135. NEXT I%
  136.  
  137. DENOM# = PI# * DENOM# / 180#   'Scale to be an area
  138. PRINT
  139. PRINT "I. eff = Illumination efficiency, S. eff = Spillover efficiency"
  140. FOR TH1% = 20 TO 90 STEP 5  'The half angle subtended by dish
  141.     NUM# = 0#
  142.     FOR I% = 1 TO TH1%
  143.     NUM# = NUM# + IN1#(I%)
  144.     NEXT I%
  145.     NUM# = PI# * NUM# / 180#
  146.  
  147.     DENI# = 0#
  148.     FOR I% = 1 TO TH1%
  149.     DENI# = DENI# + IN2#(I%)
  150.     NEXT I%
  151.     DENI# = PI# * DENI# / 180#
  152.  
  153.     K# = 2# / ((TAN(PI# * TH1% / 360#)) ^ 2)
  154.     FOD# = 1# / (4# * TAN(PI# * TH1% / 360#))
  155.     ETA# = K# * NUM# * NUM# / DENOM#
  156.     EI# = K# * NUM# * NUM# / DENI#
  157.     ES# = ETA# / EI#
  158.     PRINT USING "Half Angle=## deg, F/D=#.### "; TH1%; FOD#;
  159.     PRINT USING "Feed=###.#dB  "; 8.68589 * LOG(IFEED#(TH1%));
  160.     PRINT USING "Eff=#.### I. eff=#.### S. eff=#.###"; ETA#; EI#; ES#
  161. NEXT TH1%
  162. INPUT "Enter to continue"; ZZ$
  163. STOP
  164.  
  165. COSFEEDS:
  166. PRINT
  167. PRINT "This is an example feed that is the cosine of the angle made with the"
  168. PRINT "feed axis, raised to an exponent that can be any value (not just"
  169. PRINT "integers.)  The cosine function is used out to it's zero at 90 degrees"
  170. PRINT "after which the feed pattern has zero power.  See S.Silver, Microwave"
  171. PRINT "Antenna Theory and Design, (Rad Lab Vol 12), McGraw Hill 1949,"
  172. PRINT "pp 425-427."
  173. INPUT "Input exponent value n "; N2#
  174. N2V# = N2# / 2#'The N2# is a power function, but in this program we want volts
  175. FOR I% = 1 TO 90
  176.     IFEED#(I%) = (COS(PI# * (I% - .5) / 180#)) ^ N2V#
  177.     IF 5 * INT(I% / 5) = I% THEN GOSUB DOPR
  178. NEXT I%
  179. FOR I% = 91 TO 180
  180.     IFEED#(I%) = 0#
  181. NEXT I%
  182. INPUT "Enter to continue"; ZZ$
  183. GOTO DOINT
  184.  
  185. DOPR: PRINT USING "At ####.# deg  pattern ####.### dB"; I% - .5; 8.68589 * LOG(IFEED#(I%))
  186. RETURN
  187.  
  188.